package com.kenai.jbosh;

final class AttrVersion extends AbstractAttr<String>
  implements Comparable
{
  private static final AttrVersion DEFAULT;
  private final int major;
  private final int minor;

  static
  {
    try
    {
      DEFAULT = createFromString("1.8");
      return;
    }
    catch (BOSHException localBOSHException)
    {
      throw new IllegalStateException(localBOSHException);
    }
  }

  private AttrVersion(String paramString)
    throws BOSHException
  {
    super(paramString);
    int i = paramString.indexOf(46);
    if (i <= 0)
      throw new BOSHException("Illegal ver attribute value (not in major.minor form): " + paramString);
    String str1 = paramString.substring(0, i);
    try
    {
      this.major = Integer.parseInt(str1);
      if (this.major < 0)
        throw new BOSHException("Major version may not be < 0");
    }
    catch (NumberFormatException localNumberFormatException1)
    {
      throw new BOSHException("Could not parse ver attribute value (major ver): " + str1, localNumberFormatException1);
    }
    String str2 = paramString.substring(i + 1);
    try
    {
      this.minor = Integer.parseInt(str2);
      if (this.minor < 0)
        throw new BOSHException("Minor version may not be < 0");
    }
    catch (NumberFormatException localNumberFormatException2)
    {
      throw new BOSHException("Could not parse ver attribute value (minor ver): " + str2, localNumberFormatException2);
    }
  }

  static AttrVersion createFromString(String paramString)
    throws BOSHException
  {
    AttrVersion localAttrVersion;
    if (paramString == null)
      localAttrVersion = null;
    while (true)
    {
      return localAttrVersion;
      localAttrVersion = new AttrVersion(paramString);
    }
  }

  static AttrVersion getSupportedVersion()
  {
    return DEFAULT;
  }

  public int compareTo(Object paramObject)
  {
    int i;
    AttrVersion localAttrVersion;
    if (paramObject instanceof AttrVersion)
    {
      localAttrVersion = (AttrVersion)paramObject;
      if (this.major < localAttrVersion.major)
        i = -1;
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              return i;
              if (this.major <= localAttrVersion.major)
                break;
              i = 1;
            }
            if (this.minor >= localAttrVersion.minor)
              break;
            i = -1;
          }
          if (this.minor <= localAttrVersion.minor)
            break;
          i = 1;
        }
        i = 0;
      }
      i = 0;
    }
  }

  int getMajor()
  {
    return this.major;
  }

  int getMinor()
  {
    return this.minor;
  }
}